<?php

namespace app\circle\controller;

use think\Controller;
use think\Request;

class BaseController extends Controller
{
    private $deptId;
    private $memberId;
    private $companyId;
    private $isLogin;

    public function __construct(Request $request = null)
    {
        parent::__construct($request);
        $circleMemberDes = cookie('circleMemberDes');
        $this->isLogin = 0;
        $this->memberId = 0;
        if (!empty($circleMemberDes)) {
            $info = str_decode($circleMemberDes);
            if (!empty($info)) {
                $info = explode(config('base.login_token'), $info);
                if (count($info) == 2) {
                    $this->memberId = $info[0];
                    $this->companyId = $info[1];
                    $this->isLogin = 1;
                }
            }
        }
        $this->deptId = $this->request->param('dept_id');
        $this->assign('isLogin', $this->islogin());
    }

    public function getWxconfig()
    {
        return [
            'appid' => 'wx4a19f8a7ca3de952',
            'appsecret' => '3388b8f9c99d42e18b273447e5bd1e62'
        ];
    }

    public function getDeptId()
    {
        return $this->deptId;
    }

    public function getMemberId()
    {
        return $this->memberId;
    }

    public function getCompanyId()
    {
        return $this->getCompanyId();
    }

    public function islogin()
    {
        return $this->isLogin;
    }
}